import Login from './views/Login.vue'
import NotFound from './views/404.vue'
import Home from './views/Home.vue'
import Main from './views/Main.vue'
import Form from './views/nav1/Form.vue'
import echarts from './views/charts/echarts.vue'
import Vue from 'vue'
import Router from 'vue-router'
import Register from './views/Register'


Vue.use(Router)

export const constantRouterMap = [
// let routes = [
    {
        path: '/login',
        component: Login,
        name: '',
        hidden: true
    },
    {
        path: '/404',
        component: NotFound,
        name: '',
        hidden: true
    },
    {
        path: '/register',
        component: Register ,
        name: '注册',
        hidden: true
    },
    {
        path: '/',
        component: Home,
        name: '导航一',
        iconCls: 'el-icon-message',//图标样式class
        hidden: true,
        children: [
            { path: '/main', component: Main, name: '主页', hidden: true },
            // { path: '/table', component: Table, name: 'Table' },
            { path: '/form', component: Form, name: 'Form' },
            // { path: '/user', component: user, name: '列表' },
        ]
    },
    {
        path: '/',
        component: Home,
        name: '首页',
        iconCls: 'fa fa-bar-chart',
        leaf: true,
        children: [
            { path: '/echarts', component: echarts, name: '首页' }
        ]
    },
    // {
    //     path: '*',
    //     hidden: true,
    //     redirect: { path: '/404' }
    // }
];
// export default routes;


//异步挂载的路由
//动态需要根据权限加载的路由表
export const asyncRouterMap = [

    {
        path: '/apply',
        component: Home,
        name: '项目管理',
        redirect: '/projectApply',
        iconCls: 'fa fa-address-card',
        alwaysShow: true,
        meta: {title:'project', roles: ['admin','super_editor', "teacher", "worker"] }, //页面需要的权限
        children: [
            {
                path: '/projectApply',
                // component: ProjectIndex,
                component: () => import('./views/project/index.vue'),
                name: '项目申请',
                meta: {title:'projectApply',roles: ['admin','super_editor', "teacher"] }  //页面需要的权限
            },
            {
                path: '/projectExamine',
                component: () => import('./views/project/examine.vue'),
                name: '项目审核',
                meta: {title:'projectExamine',roles: ['admin','super_editor', "worker"] }  //页面需要的权限
            }
        ]
    },
    {
        path: '/team',
        component: Home,
        name: '团队管理',
        // redirect: '/team/index',
        iconCls: 'fa el-icon-s-custom',
        meta: {title:'team', roles: ['admin','super_editor', "teacher"] }, // 页面需要的权限
        leaf: true,
        children: [
            {
                path: '/addTeam',
                // component: Team,
                component: () => import('./views/team/index.vue'),
                name: '添加团队',
                // meta: {title:'addTeam',roles: ['admin','super_editor', "teacher"] }  // 页面需要的权限
            }
        ]
    },
    {
        path: '/conclusion',
        component: Home,
        name: '结题管理',
        iconCls:"fa el-icon-s-claim",
        redirect: '/conclusionApply',
        alwaysShow: true,
        meta: {title:'conclusion', roles: ['admin','super_editor', "teacher", "worker"] }, //页面需要的权限
        children: [
            {
                path: '/conclusionApply',
                // component: ConclusionIndex,
                component: () => import('./views/conclusion/index.vue'),
                name: '结题申请',
                meta: {title:'conclusionApply',roles: ['admin','super_editor', "teacher"] }  //页面需要的权限
            },
            {
                path: '/conclusionExamine',
                // component: ConclusionEx,
                component: () => import('./views/conclusion/examine.vue'),
                name: '结题审核',
                meta: {title:'conclusionExamine',roles: ['admin','super_editor', "worker"] }  //页面需要的权限
            }
        ]
    },

    // { path: '*', redirect: '/404', hidden: true }
];


// 创建路由
const createRouter = () => new Router({
    // mode: 'history', // 需要服务支持
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})
let router = createRouter()

// 重载路由
// export function resetRouter() {
//     const newRouter = createRouter()
//     router.matcher = newRouter.matcher // reset router
// }



export default router
